﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Linq;
using System.Windows.Input;
using ScrumFactory.Composition.ViewModel;
using ScrumFactory.Composition;
using ScrumFactory.Services;
using System.Configuration;
using ScrumFactory.Composition.View;


namespace ScrumFactory.Projects.ViewModel {

    [Export]
    public class RepositoryLogSettingsViewModel :BasePanelViewModel, IViewModel, INotifyPropertyChanged {

        public RepositoryLogSettingsViewModel() {
            SaveSettingsCommand = new DelegateCommand(SaveSettings);
        }

        public string ExternalCommand {
            get {
                return Properties.Settings.Default.RepositoryLogExternalCommand;
            }
            set {
                Properties.Settings.Default.RepositoryLogExternalCommand = value;
                OnPropertyChanged("ExternalCommand");
            }
        }

        private bool showErrorMessage;
        public bool ShowErrorMessage {
            get {
                return showErrorMessage;
            }
            set {
                showErrorMessage = value;
                OnPropertyChanged("ShowErrorMessage");
            }
        }
        

        [Import(typeof(RepositoryLogSettings))]
        public IView View { get; set; }

        public IDialogViewModel DialogViewModel { get; set; }

        private void SaveSettings() {
            Properties.Settings.Default.Save();
            if (DialogViewModel != null)
                DialogViewModel.Close();
        }

       public ICommand SaveSettingsCommand { get; set; }
    }
}
